package cn.tedu.micro.demo.common.service;

import cn.tedu.micro.demo.common.mapper.StockMapper;
import cn.tedu.micro.demo.common.pojo.po.CartPO;
import cn.tedu.micro.demo.common.pojo.po.OrderPO;
import cn.tedu.micro.demo.common.pojo.po.StockPO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.UUID;

@Service
public class StockServiceImpl implements StockService{
@Autowired
private StockMapper stockMapper;
    @Override
    public void updateStock(String productCode, Integer count) {
        UpdateWrapper<StockPO> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("product_code",productCode);
        updateWrapper.setSql("stock=stock-" + count);
        int update = stockMapper.update(null, updateWrapper);
    }
}
